package com.dreamthen.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.Date;

/**
 * @Author zengms
 * @Date 2023-11-14 19:43:25
 **/
public class User {

    @NotNull(message = "id不能为空")
    private Integer id;

    @NotNull(message = "姓名不能为空")
    @Length(min = 5, max = 10, message = "名称长度不对")
    private String name;

    @Email(regexp = "^[A-Za-z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$")
    private String email;

    @Range(max = 80, min = 18, message = "年龄范围需要在{min}-{max}之间")
    private Integer age;

    @JsonIgnore
    private String passWord;

    @Pattern(regexp = "^[\\d\\*]{7,12}$", message = "联系电话输入有误")
    private String phone;

    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date birthday;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getPassWord() {
        return passWord;
    }

    public void setPassWord(String passWord) {
        this.passWord = passWord;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public User() {
    }

    public User(Integer id, String name, String email, Integer age, String passWord, Date birthday, String phone) {
        this.id = id;
        this.name = name;
        this.email = email;
        this.age = age;
        this.passWord = passWord;
        this.birthday = birthday;
        this.phone = phone;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", email='" + email + '\'' +
                ", age=" + age +
                ", passWord='" + passWord + '\'' +
                ", birthday=" + birthday +
                ", phone=" + phone +
                '}';
    }
}
